
require('../env');
const Good = require('../app/models/goods');
const Batch = require('../app/models/batch');
const db = require('../app/db');
const knex = db.knex;
const Promise = require('bluebird');

const goods = [
    {"code":"06.01.016","name":"马桶吸","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"06.01.294","name":"棉纱手套","specs":"","仓库名称":"工程部","unit":"双","stock":"20"},
    {"code":"06.01.358","name":"云石胶","specs":"白色","仓库名称":"工程部","unit":"件","stock":"1"},
    {"code":"06.01.359","name":"云石胶","specs":"米黄","仓库名称":"工程部","unit":"件","stock":"1"},
    {"code":"06.01.360","name":"云石胶","specs":"黑色","仓库名称":"工程部","unit":"件","stock":"1"},
    {"code":"08.05.377","name":"乔郎斯LED埋地灯","specs":"52MM暖光，DC24V","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"08.05.389","name":"投影仪（奥图码）","specs":"OSW881","仓库名称":"工程部","unit":"台","stock":"1"},
    {"code":"08.05.394","name":"无线麦克风","specs":"亿歌GS111H12","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"08.06.00017","name":"网线","specs":"","仓库名称":"工程部","unit":"米","stock":"100"},
    {"code":"08.06.00046","name":"补胎","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"08.06.00072","name":"手动码钉枪","specs":"","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"08.06.00074","name":"U型钉","specs":"1008F","仓库名称":"工程部","unit":"盒","stock":"0.5"},
    {"code":"08.06.073","name":"风速仪","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"08.06.1276","name":"有线电视线","specs":"1.5米","仓库名称":"工程部","unit":"条","stock":"60"},
    {"code":"08.06.1287","name":"不锈钢卷纸轴","specs":"13.5CM","仓库名称":"工程部","unit":"条","stock":"3"},
    {"code":"08.06.1296","name":"头戴式强光手电","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"08.06.1309","name":"气动排钉枪","specs":"2-3","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"08.06.178","name":"卡侬头","specs":"","仓库名称":"工程部","unit":"个","stock":"10"},
    {"code":"08.06.503","name":"电烙铁","specs":"35W","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"08.06.795","name":"不锈钢网","specs":"0.8m","仓库名称":"工程部","unit":"米","stock":"7"},
    {"code":"08.09.322","name":"毛笔","specs":"","仓库名称":"工程部","unit":"支","stock":"5"},
    {"code":"08.09.978","name":"小博士抽屉锁","specs":"17*22","仓库名称":"工程部","unit":"把","stock":"6"},
    {"code":"08.09.980","name":"雷客点歌机","specs":"3TB","仓库名称":"工程部","unit":"台","stock":"1"},
    {"code":"08.09.981","name":"微科503E读卡头","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"08.09.997","name":"地毯胶带","specs":"","仓库名称":"工程部","unit":"卷","stock":"3"},
    {"code":"10.02.047","name":"电池","specs":"南孚/5号","仓库名称":"工程部","unit":"个","stock":"152"},
    {"code":"10.02.084","name":"电池","specs":"超霸碳性","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"10.02.159","name":"502胶水","specs":"","仓库名称":"工程部","unit":"瓶","stock":"8"},
    {"code":"11.02.226","name":"亚克力：电梯维保","specs":"","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"13.05.030","name":"0号柴油","specs":"","仓库名称":"工程部","unit":"升","stock":"2,600"},
    {"code":"13.05.037","name":"氧气","specs":"","仓库名称":"工程部","unit":"瓶","stock":"0.2"},
    {"code":"18.01.071","name":"PPR直接","specs":"Φ110","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.01.073","name":"角阀","specs":"Φ20 （4分）","仓库名称":"工程部","unit":"个","stock":"16"},
    {"code":"18.01.113","name":"单头外牙铜直接","specs":"Φ25*25","仓库名称":"工程部","unit":"个","stock":"72"},
    {"code":"18.01.114","name":"铜异形直接","specs":"Φ25*20","仓库名称":"工程部","unit":"个","stock":"71"},
    {"code":"18.01.132","name":"公牛二脚插头","specs":"10A","仓库名称":"工程部","unit":"个","stock":"15"},
    {"code":"18.01.231","name":"排水阀","specs":"","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.01.238","name":"PPR截止阀","specs":"32MM","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.01.280","name":"环形加热管","specs":"380V，9000W","仓库名称":"工程部","unit":"根","stock":"1"},
    {"code":"18.01.292","name":"不锈钢波纹水管","specs":"DN25*20CM","仓库名称":"工程部","unit":"根","stock":"2"},
    {"code":"18.01.293","name":"洗衣机下水管","specs":"","仓库名称":"工程部","unit":"条","stock":"17"},
    {"code":"18.01.311","name":"铜球阀","specs":"1寸","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.01.324","name":"生料带","specs":"","仓库名称":"工程部","unit":"个","stock":"100"},
    {"code":"18.01.343","name":"PPR90度弯头","specs":"φ110","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.01.351","name":"镀锌钢管","specs":"DN100，100*6米","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.01.359","name":"不锈钢外牙直接","specs":"4分","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.01.388","name":"不锈钢内牙直接","specs":"4分","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.01.390","name":"PPR截止阀","specs":"φ25","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.01.400","name":"金属进水软管","specs":"4分/60cm","仓库名称":"工程部","unit":"条","stock":"5"},
    {"code":"18.01.401","name":"金属进水软管","specs":"4分/1米","仓库名称":"工程部","unit":"条","stock":"5"},
    {"code":"18.02.001","name":"镇流器","specs":"40W","仓库名称":"工程部","unit":"个","stock":"10"},
    {"code":"18.02.006","name":"射灯灯头","specs":"","仓库名称":"工程部","unit":"个","stock":"57"},
    {"code":"18.02.036","name":"交流接触器","specs":"CJX2-5011  220V","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"18.02.065","name":"空气开关","specs":"DZ47-60  2P  C60A","仓库名称":"工程部","unit":"个","stock":"8"},
    {"code":"18.02.077","name":"正泰空气开关","specs":"1P32A","仓库名称":"工程部","unit":"个","stock":"9"},
    {"code":"18.03.023","name":"公牛三脚插头","specs":"10A","仓库名称":"工程部","unit":"个","stock":"17"},
    {"code":"18.03.024","name":"公牛三脚插头","specs":"16A","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.03.041","name":"明盒（线盒）","specs":"","仓库名称":"工程部","unit":"个","stock":"20"},
    {"code":"18.03.044","name":"五孔插座","specs":"86型","仓库名称":"工程部","unit":"个","stock":"10"},
    {"code":"18.03.052","name":"灭蚊灯管","specs":"T8-10W","仓库名称":"工程部","unit":"支","stock":"20"},
    {"code":"18.03.053","name":"灭蚊灯管","specs":"T8-20W","仓库名称":"工程部","unit":"支","stock":"20"},
    {"code":"18.03.056","name":"壁灯","specs":"","仓库名称":"工程部","unit":"顶","stock":"3"},
    {"code":"18.03.205","name":"人体感应开关","specs":"86面板","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.03.210","name":"LED投光灯","specs":"50W","仓库名称":"工程部","unit":"台","stock":"9"},
    {"code":"18.03.219","name":"LED投光灯","specs":"10W，暖白","仓库名称":"工程部","unit":"个","stock":"105"},
    {"code":"18.03.228","name":"LED树灯","specs":"","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.03.235","name":"照明金属卤化物灯","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.03.240","name":"COB射灯（可调角度）","specs":"5W，UZXQ-BYSD-01","仓库名称":"工程部","unit":"盏","stock":"3"},
    {"code":"18.03.241","name":"COB射灯（固定角度）","specs":"5W,UZXQ-BYSD-02","仓库名称":"工程部","unit":"盏","stock":"5"},
    {"code":"18.03.242","name":"COB深度射灯（可调角度）","specs":"12W,UZZL-BYSD-01","仓库名称":"工程部","unit":"盏","stock":"11"},
    {"code":"18.03.243","name":"筒灯（固定角度）","specs":"10W,UZHF-BYSD-01","仓库名称":"工程部","unit":"盏","stock":"3"},
    {"code":"18.03.255","name":"LED灯杯","specs":"MR16、3W、暖白光","仓库名称":"工程部","unit":"个","stock":"40"},
    {"code":"18.03.273","name":"LED方形水底壁灯","specs":"AC12V  5W暖白","仓库名称":"工程部","unit":"盏","stock":"15"},
    {"code":"18.03.277","name":"LED投光灯","specs":"30w","仓库名称":"工程部","unit":"套","stock":"8"},
    {"code":"18.03.281","name":"LDE平板灯","specs":"60*60","仓库名称":"工程部","unit":"台","stock":"3"},
    {"code":"18.03.283","name":"LED灯杯","specs":"GU10，220V，2700K","仓库名称":"工程部","unit":"个","stock":"7"},
    {"code":"18.03.284","name":"LED套管防水灯带","specs":"12V-5050暖白，5米/卷","仓库名称":"工程部","unit":"卷","stock":"5"},
    {"code":"18.03.288","name":"LED铭牌灯","specs":"3W，AC220V，暖白","仓库名称":"工程部","unit":"盏","stock":"24"},
    {"code":"18.03.293","name":"LED灯管（T5 ）","specs":"1.2m/3000k","仓库名称":"工程部","unit":"支","stock":"9"},
    {"code":"18.03.294","name":"LED灯管（T8）","specs":"1.2m/6500k","仓库名称":"工程部","unit":"支","stock":"2"},
    {"code":"18.03.296","name":"LED球泡","specs":"6500K，20W","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.03.301","name":"LED T5灯管","specs":"60cm/3000k","仓库名称":"工程部","unit":"支","stock":"12"},
    {"code":"18.03.309","name":"欧司朗节能灯荧光灯","specs":"13W2针暖光3000k","仓库名称":"工程部","unit":"个","stock":"14"},
    {"code":"18.03.310","name":"LED楼道感应灯","specs":"圆形","仓库名称":"工程部","unit":"套","stock":"4"},
    {"code":"18.04.003","name":"水龙头","specs":"4分不锈钢","仓库名称":"工程部","unit":"个","stock":"17"},
    {"code":"18.04.004","name":"淋浴软管","specs":"1.5米","仓库名称":"工程部","unit":"条","stock":"2"},
    {"code":"18.04.015","name":"保温桶水龙头","specs":"4分","仓库名称":"工程部","unit":"个","stock":"20"},
    {"code":"18.04.021","name":"水位控制器","specs":"SK-H型","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.04.029","name":"淋浴花洒","specs":"","仓库名称":"工程部","unit":"个","stock":"9"},
    {"code":"18.04.030","name":"不锈钢下水器","specs":"","仓库名称":"工程部","unit":"个","stock":"10"},
    {"code":"18.04.038","name":"水位报警器","specs":"接触式探头","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.04.043","name":"PVC防水盒","specs":"","仓库名称":"工程部","unit":"个","stock":"14"},
    {"code":"18.04.044","name":"热水表芯","specs":"DN100","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.04.061","name":"三相发热管","specs":"9KW","仓库名称":"工程部","unit":"根","stock":"1"},
    {"code":"18.04.062","name":"混合阀进水软管","specs":"","仓库名称":"工程部","unit":"条","stock":"3"},
    {"code":"18.04.067","name":"洗衣机水龙头出水嘴","specs":"4分，带垫片","仓库名称":"工程部","unit":"个","stock":"16"},
    {"code":"18.04.62","name":"三相加热管","specs":"6KW","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.04.63","name":"溪山摇摆水龙头","specs":"4分","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.04.64","name":"溪山单冷菜盆水龙头","specs":"4分","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.04.65","name":"插座面板","specs":"16A","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.05.012","name":"铁丝","specs":"斤","仓库名称":"工程部","unit":"市斤","stock":"5"},
    {"code":"18.05.105","name":"博世钻头","specs":"25#","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.05.120","name":"C式气动快速接头","specs":"公母8#","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.05.129","name":"搓丝钉","specs":"80mm","仓库名称":"工程部","unit":"盒","stock":"5"},
    {"code":"18.05.133","name":"钩锁","specs":"16MM","仓库名称":"工程部","unit":"把","stock":"7"},
    {"code":"18.06.001","name":"电笔","specs":"","仓库名称":"工程部","unit":"支","stock":"5"},
    {"code":"18.06.003","name":"玻璃胶枪","specs":"","仓库名称":"工程部","unit":"支","stock":"2"},
    {"code":"18.06.010","name":"氩气瓶","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.016","name":"切割片（大）","specs":"350","仓库名称":"工程部","unit":"片","stock":"2"},
    {"code":"18.06.021","name":"海德曼无线门铃","specs":"j-288","仓库名称":"工程部","unit":"套","stock":"3"},
    {"code":"18.06.036","name":"博世切割片","specs":"8寸","仓库名称":"工程部","unit":"片","stock":"2"},
    {"code":"18.06.048","name":"电容","specs":"1.5uF","仓库名称":"工程部","unit":"粒","stock":"6"},
    {"code":"18.06.085","name":"Φ50大理石开孔器","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.086","name":"40齿锯片","specs":"","仓库名称":"工程部","unit":"片","stock":"1"},
    {"code":"18.06.087","name":"皮带","specs":"C-1321","仓库名称":"工程部","unit":"条","stock":"3"},
    {"code":"18.06.131","name":"电缆线","specs":"2*1.5平","仓库名称":"工程部","unit":"米","stock":"50"},
    {"code":"18.06.159","name":"LED变压器","specs":"400W","仓库名称":"工程部","unit":"台","stock":"1"},
    {"code":"18.06.200","name":"不锈钢合页","specs":"4寸","仓库名称":"工程部","unit":"副","stock":"2"},
    {"code":"18.06.203","name":"PVC割管刀","specs":"","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.06.246","name":"马桶进水器","specs":"","仓库名称":"工程部","unit":"个","stock":"7"},
    {"code":"18.06.252","name":"PPR双活接球阀","specs":"32mm","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.253","name":"PPR双活接球阀","specs":"40mm","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.274","name":"博世钻头","specs":"8mm","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.06.275","name":"博世钻头","specs":"10mm","仓库名称":"工程部","unit":"支","stock":"1"},
    {"code":"18.06.287","name":"母插簧接线端子","specs":"","仓库名称":"工程部","unit":"包","stock":"0.3"},
    {"code":"18.06.291","name":"LED防水硬灯条","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.296","name":"陶瓷保险丝","specs":"","仓库名称":"工程部","unit":"个","stock":"7"},
    {"code":"18.06.307","name":"氩弧焊枪磁嘴","specs":"150A，6*30MM","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"18.06.308","name":"氩弧焊枪乌针夹","specs":"150A，36*1.6MM","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.06.313","name":"机械旋钮温控器","specs":"30--110摄氏度","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.318","name":"按钮开关","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.320","name":"砂纸架","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.322","name":"冰箱加液单向阀","specs":"长：8cm","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.06.350","name":"透明上盖","specs":"水泵配件","仓库名称":"工程部","unit":"个","stock":"10"},
    {"code":"18.06.351","name":"上盖密封圈","specs":"水泵配件","仓库名称":"工程部","unit":"条","stock":"10"},
    {"code":"18.06.353","name":"无铅锡丝","specs":"0.8MM，500G","仓库名称":"工程部","unit":"卷","stock":"0.5"},
    {"code":"18.06.356","name":"防水变压器","specs":"AC12V，200W","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.357","name":"限位微动开关","specs":"V-15-1C25","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.06.358","name":"皮带","specs":"A-1092Li","仓库名称":"工程部","unit":"条","stock":"2"},
    {"code":"18.06.363","name":"圆形裸接线端子","specs":"OT4-5，1000个/包","仓库名称":"工程部","unit":"包","stock":"0.1"},
    {"code":"18.06.364","name":"U型裸接线端子","specs":"UT2.5-4，1000个/包","仓库名称":"工程部","unit":"包","stock":"0.1"},
    {"code":"18.06.365","name":"母预绝缘接线端子","specs":"FDD2-187，1000个/包","仓库名称":"工程部","unit":"包","stock":"0.1"},
    {"code":"18.06.374","name":"皮带","specs":"O－480E","仓库名称":"工程部","unit":"条","stock":"5"},
    {"code":"18.06.409","name":"压力表","specs":"4分","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.418","name":"小便池感应器","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.436","name":"结构胶胶枪","specs":"","仓库名称":"工程部","unit":"把","stock":"2"},
    {"code":"18.06.437","name":"白色检修孔","specs":"40*40","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.453","name":"多功能潜水泵","specs":"220V/150W","仓库名称":"工程部","unit":"台","stock":"2"},
    {"code":"18.06.469","name":"不锈钢门吸（套）","specs":"","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.06.471","name":"冲击钻钻头","specs":"18×250","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.472","name":"电刨皮带","specs":"橡胶F20皮带","仓库名称":"工程部","unit":"条","stock":"5"},
    {"code":"18.06.473","name":"管道疏通器","specs":"","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"18.06.479","name":"微时时控器","specs":"","仓库名称":"工程部","unit":"个","stock":"8"},
    {"code":"18.06.480","name":"梅花电瓶","specs":"12v/150AH","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.481","name":"大红鹰电瓶充电器","specs":"12v/24v/60AH","仓库名称":"工程部","unit":"台","stock":"1"},
    {"code":"18.06.483","name":"门栓","specs":"250mm","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.490","name":"欧德闭门器","specs":"暗藏式","仓库名称":"工程部","unit":"台","stock":"6"},
    {"code":"18.06.495","name":"R22转410R接头（180°C）","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.496","name":"R22转410R接头（120°C）","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.497","name":"R22转410R接头（90°C）","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.501","name":"波盾气动喷砂枪","specs":"","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"18.06.503","name":"泰盛温控器","specs":"CD6000/K400","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.06.505","name":"绿岛风管道排气扇","specs":"DPT15-34","仓库名称":"工程部","unit":"台","stock":"5"},
    {"code":"18.06.507","name":"方形花洒","specs":"10英寸","仓库名称":"工程部","unit":"个","stock":"9"},
    {"code":"18.06.508","name":"法兰式冷水表","specs":"φ160","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.512","name":"木工刨","specs":"35CM","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"18.06.514","name":"电容","specs":"80UF","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.515","name":"多士炉云母加热片","specs":"220v*500W,150*145","仓库名称":"工程部","unit":"块","stock":"4"},
    {"code":"18.06.516","name":"烧水壶温控开关","specs":"16A","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"18.06.517","name":"多功能五孔开关面板","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.06.519","name":"调光开关面板","specs":"","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"18.06.526","name":"手电钻夹头扳手","specs":"13MM","仓库名称":"工程部","unit":"把","stock":"2"},
    {"code":"18.06.530","name":"抹泥刀","specs":"1号","仓库名称":"工程部","unit":"把","stock":"3"},
    {"code":"18.06.538","name":"涂料枪喷壶","specs":"OK-99","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"18.06.540","name":"管钳","specs":"24寸","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"18.06.541","name":"热熔胶枪","specs":"","仓库名称":"工程部","unit":"把","stock":"1"},
    {"code":"18.06.544","name":"全铜提拉帽","specs":"M5","仓库名称":"工程部","unit":"个","stock":"6"},
    {"code":"18.06.548","name":"6.5头音频焊接头","specs":"","仓库名称":"工程部","unit":"个","stock":"5"},
    {"code":"18.06.549","name":"固特执手锁","specs":"3516-N青古铜","仓库名称":"工程部","unit":"套","stock":"4"},
    {"code":"18.06.551","name":"防火门门锁","specs":"35-55mm","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.06.554","name":"液位浮球开关","specs":"","仓库名称":"工程部","unit":"个","stock":"3"},
    {"code":"18.06.555","name":"卤素灯杯","specs":"MR16","仓库名称":"工程部","unit":"个","stock":"260"},
    {"code":"18.06.556","name":"抽屉轨道","specs":"10寸，三节","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.566","name":"猪毛刷","specs":"2.5寸","仓库名称":"工程部","unit":"把","stock":"10"},
    {"code":"18.06.572","name":"直饮机龙头","specs":"031","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.573","name":"桑拿门合页","specs":"","仓库名称":"工程部","unit":"套","stock":"2"},
    {"code":"18.06.574","name":"卤素灯杯变压器","specs":"AC12V","仓库名称":"工程部","unit":"个","stock":"15"},
    {"code":"18.06.575","name":"混水阀芯","specs":"35mm平脚","仓库名称":"工程部","unit":"个","stock":"6"},
    {"code":"18.06.576","name":"混水阀芯","specs":"35mm高脚","仓库名称":"工程部","unit":"个","stock":"9"},
    {"code":"18.06.577","name":"冰箱启动器","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.06.578","name":"公牛无线排插","specs":"6位","仓库名称":"工程部","unit":"个","stock":"9"},
    {"code":"18.06.579","name":"猪毛刷","specs":"1.5寸","仓库名称":"工程部","unit":"把","stock":"10"},
    {"code":"18.06.580","name":"污水泵线圈+轴承","specs":"","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"18.06.581","name":"热水表","specs":"DN20 6分","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.07.036","name":"滚筒刷","specs":"","仓库名称":"工程部","unit":"把","stock":"2"},
    {"code":"18.07.048","name":"2.5#线槽","specs":"","仓库名称":"工程部","unit":"支","stock":"3"},
    {"code":"18.07.052","name":"白水泥","specs":"","仓库名称":"工程部","unit":"包","stock":"1"},
    {"code":"18.07.176","name":"耐火沙","specs":"","仓库名称":"工程部","unit":"市斤","stock":"20"},
    {"code":"18.07.178","name":"德高堵漏王","specs":"2kg/包","仓库名称":"工程部","unit":"包","stock":"10"},
    {"code":"18.07.183","name":"砂纸","specs":"NO.300#","仓库名称":"工程部","unit":"张","stock":"60"},
    {"code":"18.07.209","name":"电工胶带","specs":"3m","仓库名称":"工程部","unit":"卷","stock":"150"},
    {"code":"18.07.231","name":"包芯尼龙绳","specs":"5mm   100米/卷","仓库名称":"工程部","unit":"卷","stock":"0.9"},
    {"code":"18.07.239","name":"稀释剂","specs":"3L/桶","仓库名称":"工程部","unit":"桶","stock":"0.4"},
    {"code":"18.07.241","name":"AB胶","specs":"40g+40g","仓库名称":"工程部","unit":"盒","stock":"15"},
    {"code":"18.07.249","name":"AB干挂胶","specs":"5L/桶","仓库名称":"工程部","unit":"桶","stock":"0.4"},
    {"code":"18.07.251","name":"正泰空气开关","specs":"3*60A","仓库名称":"工程部","unit":"个","stock":"7"},
    {"code":"18.07.254","name":"多乐士外墙漆","specs":"20kg/桶（15L）","仓库名称":"工程部","unit":"桶","stock":"1.8"},
    {"code":"18.07.255","name":"朱砂红油漆","specs":"16kg/桶","仓库名称":"工程部","unit":"桶","stock":"0.4"},
    {"code":"18.07.265","name":"外邦透明腻子","specs":"2L/桶","仓库名称":"工程部","unit":"桶","stock":"0.2"},
    {"code":"18.07.266","name":"华润聚氨酯木质漆","specs":"4kg/桶，3合一","仓库名称":"工程部","unit":"组","stock":"0.4"},
    {"code":"18.07.269","name":"除锈剂","specs":"450ML/瓶","仓库名称":"工程部","unit":"瓶","stock":"6"},
    {"code":"18.07.274","name":"万能胶","specs":"3L/桶","仓库名称":"工程部","unit":"桶","stock":"0.2"},
    {"code":"18.07.275","name":"水性木器漆","specs":"白色，800G/桶","仓库名称":"工程部","unit":"桶","stock":"0.2"},
    {"code":"18.07.286","name":"3M自粘胶布","specs":"耐高温","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.07.290","name":"秦博士补漏膏","specs":"1L/桶，806","仓库名称":"工程部","unit":"瓶","stock":"2"},
    {"code":"18.07.291","name":"多股软芯电缆","specs":"3*6","仓库名称":"工程部","unit":"米","stock":"55"},
    {"code":"18.07.292","name":"正泰空气开关","specs":"2P40A","仓库名称":"工程部","unit":"个","stock":"7"},
    {"code":"18.07.293","name":"正泰空气开关","specs":"1P20A","仓库名称":"工程部","unit":"个","stock":"8"},
    {"code":"18.08.010","name":"铁丝网","specs":"","仓库名称":"工程部","unit":"米","stock":"10"},
    {"code":"18.08.011","name":"砂轮割片","specs":"100MM","仓库名称":"工程部","unit":"个","stock":"6"},
    {"code":"18.08.0138","name":"黑色自攻螺丝","specs":"M4*3.2","仓库名称":"工程部","unit":"千克","stock":"0.1"},
    {"code":"18.08.0139","name":"黑色自攻螺丝","specs":"M4*50","仓库名称":"工程部","unit":"千克","stock":"0.1"},
    {"code":"18.08.049","name":"R22空调制冷剂","specs":"13.6KG/瓶","仓库名称":"工程部","unit":"瓶","stock":"1"},
    {"code":"18.08.128","name":"玻璃胶","specs":"醇古铜红","仓库名称":"工程部","unit":"瓶","stock":"3"},
    {"code":"18.08.132","name":"四层货架","specs":"200*60*200    250KG","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.08.133","name":"泡沫发泡剂","specs":"","仓库名称":"工程部","unit":"瓶","stock":"1"},
    {"code":"18.08.135","name":"PVC地漏","specs":"φ110mm","仓库名称":"工程部","unit":"个","stock":"6"},
    {"code":"18.08.154","name":"不锈钢油灰刀","specs":"","仓库名称":"工程部","unit":"把","stock":"3"},
    {"code":"18.08.165","name":"木头开孔器","specs":"35MM","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.08.171","name":"LED灯珠（G4）","specs":"AC12V  3000K","仓库名称":"工程部","unit":"个","stock":"22"},
    {"code":"18.08.178","name":"木工合金开孔器","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.08.186","name":"色精（红）","specs":"500G/瓶","仓库名称":"工程部","unit":"瓶","stock":"0.2"},
    {"code":"18.08.187","name":"色精（黄）","specs":"500G/瓶","仓库名称":"工程部","unit":"瓶","stock":"0.2"},
    {"code":"18.08.188","name":"色精（黑）","specs":"500G/瓶","仓库名称":"工程部","unit":"瓶","stock":"0.2"},
    {"code":"18.08.200","name":"手喷漆","specs":"红色","仓库名称":"工程部","unit":"瓶","stock":"1"},
    {"code":"18.08.232","name":"壁挂式马桶冲水箱","specs":"","仓库名称":"工程部","unit":"套","stock":"3"},
    {"code":"18.08.237","name":"单芯铜线","specs":"2.5MM，红色","仓库名称":"工程部","unit":"米","stock":"100"},
    {"code":"18.08.238","name":"单芯铜线","specs":"2.5MM，蓝色","仓库名称":"工程部","unit":"米","stock":"100"},
    {"code":"18.08.241","name":"地下室标记灯","specs":"","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.08.248","name":"旋钮温控","specs":"WKB-300，220V   50℃-300℃","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.08.261","name":"氧气瓶","specs":"10L","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.08.294","name":"快速接线端子","specs":"1.5M","仓库名称":"工程部","unit":"包","stock":"0.2"},
    {"code":"18.08.295","name":"快速接线端子","specs":"2.5","仓库名称":"工程部","unit":"包","stock":"0.2"},
    {"code":"18.08.296","name":"快速接线端子","specs":"6M","仓库名称":"工程部","unit":"包","stock":"0.2"},
    {"code":"18.08.303","name":"PVC取水器（含不锈钢外牙直接）","specs":"6分","仓库名称":"工程部","unit":"个","stock":"4"},
    {"code":"18.08.323","name":"R12制冷剂","specs":"13.6KG/瓶","仓库名称":"工程部","unit":"瓶","stock":"0.5"},
    {"code":"18.08.340","name":"2.5线槽","specs":"","仓库名称":"工程部","unit":"条","stock":"10"},
    {"code":"18.08.343","name":"强磁套筒","specs":"8#","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.08.345","name":"W型燃气加热管","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.08.351","name":"USB转接网口","specs":"","仓库名称":"工程部","unit":"个","stock":"1"},
    {"code":"18.08.357","name":"钢丝绳","specs":"8MM","仓库名称":"工程部","unit":"米","stock":"30"},
    {"code":"18.08.359","name":"紧线器","specs":"2吨","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"18.08.362","name":"绿网","specs":"加厚8M宽","仓库名称":"工程部","unit":"平方米","stock":"460"},
    {"code":"18.08.380","name":"10#锁扣","specs":"10#","仓库名称":"工程部","unit":"个","stock":"8"},
    {"code":"18.08.382","name":"音响支架","specs":"","仓库名称":"工程部","unit":"套","stock":"1"},
    {"code":"18.08.384","name":"正泰交流接触器","specs":"3201/220V","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.08.386","name":"管道式换气扇","specs":"28W","仓库名称":"工程部","unit":"台","stock":"2"},
    {"code":"18.08.400","name":"白乳胶","specs":"标牌，5.5KG/桶","仓库名称":"工程部","unit":"桶","stock":"0.9"},
    {"code":"18.08.402","name":"不锈钢大弯胶链","specs":"40#胶卸式","仓库名称":"工程部","unit":"套","stock":"12"},
    {"code":"18.08.403","name":"纽扣电池","specs":"CR2032","仓库名称":"工程部","unit":"个","stock":"2"},
    {"code":"18.08.422","name":"静音PU轮","specs":"4寸","仓库名称":"工程部","unit":"个","stock":"8"},
    {"code":"18.08.423","name":"双芯音频话筒线","specs":"100米/卷","仓库名称":"工程部","unit":"米","stock":"50"},
    {"code":"18.08.425","name":"防火门闭门器","specs":"19mm*162mm","仓库名称":"工程部","unit":"套","stock":"10"},
    {"code":"18.08.437","name":"黑色尼龙扎带","specs":"8*500","仓库名称":"工程部","unit":"包","stock":"0.5"},
    {"code":"18.08.438","name":"黑色尼龙扎带","specs":"8*350","仓库名称":"工程部","unit":"包","stock":"1"},
    {"code":"18.08.439","name":"黑色尼龙扎带","specs":"8*700","仓库名称":"工程部","unit":"包","stock":"0.5"},
    {"code":"18.08.440","name":"黑色尼龙扎带","specs":"8*200","仓库名称":"工程部","unit":"包","stock":"1"},
    {"code":"18.08.448","name":"绝缘胶带（大）","specs":"醋酸耐高温","仓库名称":"工程部","unit":"卷","stock":"39"},
    {"code":"18.08.454","name":"地槽","specs":"","仓库名称":"工程部","unit":"条","stock":"4"},
    {"code":"18.08.456","name":"汽油机油","specs":"15W-40/4L","仓库名称":"工程部","unit":"瓶","stock":"1"},
    {"code":"18.08.457","name":"环氧树脂AB胶","specs":"2KG/组","仓库名称":"工程部","unit":"组","stock":"0.8"},
    {"code":"18.08.459","name":"盆景循环泵","specs":"12W","仓库名称":"工程部","unit":"台","stock":"1"},
    {"code":"18.09.011","name":"洗衣机进水管","specs":"","仓库名称":"工程部","unit":"条","stock":"4"},
];

return Promise.try(() => {
    return goods;
})
.map(item => {
    return Good.where({
        name: item.name,
        code: item.code
    })
    .fetch()
    .then(egood => {
        if(egood) {
            return egood;
        }
        return Good.safeForge({
            code: item.code,
            name: item.name,
            specs: item.specs,
            unit: item.unit
        })
        .save();
    })
    .then(good => {
        console.log(good.get('name'), '入库', item.stock);
        if(parseFloat(item.stock)) {
            return Batch.safeForge({
                good_id: good.get('id'),
                stock: parseFloat(item.stock),
                price: 0,
            })
            .save()
            .then(() => {
                good.safeSet({
                    stock: good.get('stock') + parseFloat(item.stock)
                });
        
                return good.save();
            });
        }
    });
})
.then(() => {
    return db.knex.destroy();
})